package Server.TechnicalServices.Mapper;

import java.util.ArrayList;

import Server.Entity.Dominio.ELineaTask;
import Server.Entity.IceClasses.ELineaTaskI;

public class MLineaTask implements Mapper{

	@Override
	public ELineaTaskI getIceObj(Object hibObj) {

		ELineaTaskI iceLineaTask = null;
		MLineaTimeRecord lineaMapper = new MLineaTimeRecord();			
		
		if ( hibObj instanceof ELineaTask)
		{
			iceLineaTask = new ELineaTaskI();
			iceLineaTask.lineeTimeRecord= new ArrayList<EntityCondivise.ELineaTimeRecord>();
			
			iceLineaTask.costo = ((ELineaTask) hibObj).getCosto();
			iceLineaTask.descrizione = ((ELineaTask) hibObj).getDescrizione();
			iceLineaTask.misura = ((ELineaTask) hibObj).getMisura();
			
			for( Server.Entity.Dominio.ELineaTimeRecord hibLine: ((ELineaTask) hibObj).getLineeTimerecord() )
				iceLineaTask.lineeTimeRecord.add( lineaMapper.getIceObj(hibLine) );	
		}
		
		return iceLineaTask;
	}

	@Override
	public ELineaTask getHibObj(Object iceObj) {

		ELineaTask hibLineaTask = null;
		MLineaTimeRecord lineaMapper = new MLineaTimeRecord();			
		
		if ( iceObj instanceof ELineaTaskI)
		{
			hibLineaTask = new ELineaTask();
			hibLineaTask.setLineeTimerecord(new ArrayList<Server.Entity.Dominio.ELineaTimeRecord>());
			
			hibLineaTask.setCosto(((ELineaTaskI) iceObj).costo);
			hibLineaTask.setDescrizione(((ELineaTaskI) iceObj).descrizione);
			hibLineaTask.setMisura(((ELineaTaskI) iceObj).misura);
			
			for(EntityCondivise.ELineaTimeRecord iceTrLine: ((ELineaTaskI) iceObj).lineeTimeRecord)
				hibLineaTask.getLineeTimerecord().add( lineaMapper.getHibObj(iceTrLine) );
		}
		
		return hibLineaTask;
		
	}
	
}
